// 设计关于页面

// 关闭VSCode非必要报错
// ignore_for_file: camel_case_types, non_constant_identifier_names

import 'package:flutter/material.dart';
import 'package:project_award_statistics/utils/my_yaru_buttons/my_yaru_button_confirmed.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:window_manager/window_manager.dart';

class AboutPage_Desktop extends StatefulWidget {
  const AboutPage_Desktop({super.key});

  @override
  State<AboutPage_Desktop> createState() => _AboutPage_DesktopState();
}

class _AboutPage_DesktopState extends State<AboutPage_Desktop>
    with TickerProviderStateMixin {
  // 初始化动画控制总线
  late AnimationController _animationController_widget1; // 初始化动画总线1
  late AnimationController _animationController_widget2; // 初始化动画总线2

  // 打开西北民族大学网页的调用函数
  void launch_xbmu_website() {
    String url = 'https://www.xbmu.edu.cn';
    final Uri uri = Uri.parse(url); //将url字符串转换为url对象uri
    launchUrl(uri);
  }

  // 覆写父类构造函数
  @override
  void initState() {
    // 初始化动画总线1
    _animationController_widget1 = AnimationController(
      duration: Duration(seconds: 1), // 设置动画持续时间
      vsync: this,
    );
    // 初始化动画总线2
    _animationController_widget2 = AnimationController(
      duration: Duration(seconds: 1), // 设置动画持续时间
      vsync: this,
    );

    // 动画,启动!
    _animationController_widget1.forward();
    _animationController_widget2.forward();

    super.initState();
  }

  // 一键停止动画并释放动画对象的函数
  void animation_dispose ()
    {
      _animationController_widget1.stop();
      _animationController_widget2.stop();
      _animationController_widget1.dispose();
      _animationController_widget2.dispose();
    }

  // 覆写父类析构函数
  @override
  void dispose ()
    {
      animation_dispose();
      super.dispose();
    }

  @override
  Widget build(BuildContext context) {
    // 更改窗口标题文字
    WindowManager.instance.setTitle("关于本程序");
    // 初始化程序总框架
    return Scaffold(
      backgroundColor: Colors.white,
      body: Padding(
        padding: EdgeInsets.only(top: 20,bottom: 60),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(
              // 列式布局放置西北民族大学电子工作室徽标
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                SlideTransition(
                  position: Tween<Offset>(
                    begin: Offset(-3.5, 0),
                    end: Offset.zero,
                  ).animate(
                    CurvedAnimation(
                      parent: _animationController_widget1,
                      curve: Curves.easeInOut,
                    ),
                  ),
                  child: Image.asset(
                    "lib/images/northwest_minzu_university_icon.png",
                    width: 160,
                    height: 160,
                  ),
                ),

                const SizedBox(width: 55),

                SlideTransition(
                  position: Tween<Offset>(
                    begin: Offset(3.5, 0),
                    end: Offset.zero,
                  ).animate(
                    CurvedAnimation(
                      parent: _animationController_widget2,
                      curve: Curves.easeInOut,
                    ),
                  ),
                  child: Column(
                    children: [
                      Text(
                        "西北民族大学",
                        style: TextStyle(
                          color: Colors.black,
                          fontSize: 50,
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                      SizedBox(height: 16), //设置两行字体间的一定间距
                      Text(
                        "荣誉出品",
                        style: TextStyle(color: Colors.black, fontSize: 45),
                      ),
                    ],
                  ),
                ),
              ],
            ),
            Text(
              //设置应用介绍文本样式
              "该软件用于西北民族大学电子设计工作室查询个人的获奖信息以及修改个人获奖信息。",
              style: TextStyle(fontSize: 20, color: Colors.black),
            ),
            SizedBox(
              width: 300,
              height: 50,
              child: MyYaruButton_Confirmed(
                text: "快点击我访问西北民族大学网站",
                onPressed: launch_xbmu_website,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
